﻿@using Beaver
@using Beaver.Dtos
@using Beaver.Models
@{
    var currentPath = Context.Request.Path;
    var menus = new List<MenuItemDto>
{
        new MenuItemDto
        {
            Name = "控制台",
            Path = "/Workbench/Dashboard",
            Icon = "layui-icon-app",
        },
        new MenuItemDto
        {
            Name = "系统管理",
            Icon = "layui-icon-set",
            Children = new List<MenuItemDto>
            {
                new MenuItemDto
                {
                    Name = "组织机构",
                    Path = "/System/OrganizationUnit",
                    Icon = "layui-icon-link",
                },
                new MenuItemDto
                {
                    Name = "角色",
                    Path = "/System/Role",
                    Icon = "layui-icon-component",
                },
                new MenuItemDto
                {
                    Name = "用户",
                    Path = "/System/User",
                    Icon = "layui-icon-link",
                },
                new MenuItemDto
                {
                    Name = "声明类型",
                    Path = "/System/ClaimType",
                    Icon = "layui-icon-link",
                },
                new MenuItemDto
                {
                    Name = "安全日志",
                    Path = "/System/SecurityLog",
                    Icon = "layui-icon-link",
                },
            }
        },
    };
}

<ul class="layui-nav layui-nav-tree" lay-filter="navMenu" lay-accordion>
    @foreach (var item in menus)
    {
        if (item.Children.Count == 0)
        {
            <li class="layui-nav-item @(currentPath == item.Path ? "layui-this" : "")">
                <a href="@item.Path">
                    @if (!string.IsNullOrWhiteSpace(item.Icon))
                    {
                        <i class="layui-icon @item.Icon"></i>
                    }
                    @item.Name
                </a>
            </li>
            continue;
        }
        <li class="layui-nav-item @(item.Children.Where(x => x.Path==currentPath).Any() ? "layui-nav-itemed" : "")">
            <a class="" href="javascript:;">
                @if (!string.IsNullOrWhiteSpace(item.Icon))
                {
                    <i class="layui-icon @item.Icon"></i>
                }
                @item.Name
            </a>
            <dl class="layui-nav-child">
                @foreach (var child in item.Children)
                {
                    <dd class="@(currentPath == child.Path ? "layui-this" : "")">
                        <a href="@child.Path">
                            @if (!string.IsNullOrWhiteSpace(child.Icon))
                            {
                                <i class="layui-icon @child.Icon"></i>
                            }
                            @child.Name
                        </a>
                    </dd>
                }
            </dl>
        </li>
    }

    @*<li class="layui-nav-item layui-nav-itemed">
            <a class="" href="javascript:;"> <i class="layui-icon layui-icon-face-smile"></i> menu group 1</a>
            <dl class="layui-nav-child">
                <dd><a href="javascript:;"> <i class="layui-icon layui-icon-face-smile"></i> menu 1</a></dd>
                <dd><a href="javascript:;">menu 2</a></dd>
                <dd><a href="javascript:;">menu 3</a></dd>
                <dd><a href="javascript:;">the links</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item">
            <a href="javascript:;">menu group 2</a>
            <dl class="layui-nav-child">
                <dd><a href="javascript:;" class="layui-this">list 1</a></dd>
                <dd><a href="javascript:;">list 2</a></dd>
                <dd><a href="javascript:;">超链接</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item @(path=="/" ?"layui-this":"")"><a asp-controller="Home" asp-action="Index">主页</a></li>
        <li class="layui-nav-item @(path=="/Home/Privacy" ?"layui-this":"")"><a asp-controller="Home" asp-action="Privacy">通讯配置</a></li>
        <li class="layui-nav-item"><a href="javascript:;">设备信息</a></li>
        <li class="layui-nav-item"><a href="javascript:;">待推送数据</a></li>*@
</ul>
